package com.soulless.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author zenglei
 * @Description 功能描述
 * @date 2020/7/28 20:51
 */
@Controller
public class IndexController {

    @RequestMapping("/api/index")
    public Object index() {
        return "index";
    }


    @Autowired
    private ElasticsearchTemplate elasticsearchTemplate;

    /**
     * 创建索引和创建字段映射
     */
    @RequestMapping("/api/ci")
    @ResponseBody
    public String createIndex() {
        elasticsearchTemplate.createIndex("testes");
//        log.info("创建索引成功");
//        elasticsearchTemplate.putMapping(Item.class);
//        log.info("字段映射成功");
        return "创建索引成功";
    }

}
